package com.wzy.mall.web.servlet.client;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/mall/user/*")
public class UserServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String requestURI = request.getRequestURI();
        String action = requestURI.replace("/api/mall/user/", "");
        if("login".equals(action)) {
            User.login(request, response);

        } else if("signup".equals(action)) {
            User.signup(request, response);

        } else if("data".equals(action)) {
            User.data(request, response);

        } else if("updatePwd".equals(action)) {
            User.updatePwd(request, response);

        } else if("updateUserData".equals(action)) {
            User.updateUserData(request, response);

        } else if("logoutClient".equals(action)) {
            User.logoutClient(request, response);

        }
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.doPost(request, response);
    }
}
